import { IsEmail, IsString, IsOptional, IsEnum, MinLength, Matches } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { Gender } from '@prisma/client';

export class RegisterDto {
  @ApiProperty({ description: 'Email address', example: 'user@example.com' })
  @IsEmail({}, { message: 'Please enter a valid email address' })
  email: string;

  @ApiProperty({ description: 'Phone number', example: '13333333333', required: false })
  @IsOptional()
  @IsString()
  @Matches(/^1[3-9]\d{9}$/, { message: 'Please enter a valid phone number' })
  phone?: string;

  @ApiProperty({ description: 'Password', example: 'password123', minLength: 8 })
  @IsString()
  @MinLength(8, { message: 'Password must be at least 8 characters' })
  @Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/, { 
    message: 'Password must contain uppercase, lowercase letters and numbers' 
  })
  password: string;

  @ApiProperty({ description: 'Gender', enum: Gender, example: Gender.MALE })
  @IsEnum(Gender, { message: 'Gender must be MALE, FEMALE or UNKNOWN' })
  gender: Gender;

  @ApiProperty({ description: 'Nickname', example: 'User nickname', required: false })
  @IsOptional()
  @IsString()
  nickname?: string;
}
